package com.yjd.bi.report.enums;

/**
 * 时间维度
 * 
 * @author chenpengfei
 * 
 */
public enum TimeType {

	DAY(1, 30), WEEK(2, 12), MONTH(3, 12);

	/**
	 * 代号
	 */
	private int code;
	/**
	 * 单元数目
	 */
	private int unit;

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public int getUnit() {
		return unit;
	}

	public void setUnit(int unit) {
		this.unit = unit;
	}

	private TimeType(int code, int unit) {
		this.code = code;
		this.unit = unit;
	}

	public static TimeType getType(int code) {
		for (TimeType t : TimeType.values()) {
			if (t.getCode() == code)
				return t;
		}
		return null;
	}
}
